<html>
<head>
<title>管理系统</title>
<meta http-equiv=Content-Type content=text/html;charset=utf-8>
<#include "../inc/commonJs.html">
<script type="text/JavaScript">
//页面加载  
var grid;
var windowparam = '';
$(function(){
	//加载数据  
    grid = $('#projectgrid').datagrid({  
        url:'listProject.do',  
        loadMsg:'数据加载中请稍后……',  
        striped: true,  
        pagination: true,  
        rownumbers: true,     
        singleSelect : true, 
        pageSize: [${syscfg.pageSize!10}],
        pageList: [${syscfg.pageList!10}],
        //queryParams: {fid: 0},
        columns:[[  
             {field:'projectid',title: 'ID',align: 'center',width: '50'},  
             {field:'name',title: '项目名称',align: 'center',width: '200'},
             {field:'starttime',title: '开始时间',align: 'center',width: '150'},
             {field:'stoptime',title: '结束时间',align: 'center',width: '150'},
             {field:'zt',title: '状态',align: 'center',width: '100',
             	formatter: function(value,rowdata,index){
             		var str = '';
             		if(value == 0){
						str = '未开始';
             		}else if(value == 1){
             			str ='进行中';
             		}else if(value ==2){
             			str = '已完成';
             		}else if(value == 3){
             			str = '已归档';
             		}
					return str;
				}
             },
             {field:'content',title: '介绍',align: 'center',width: '300'}
         ]],
         toolbar : [btn_add, btn_edit, btn_del, '-']
     });
     $("#tree").tree({
            method: "post",
            lines: true,
            url: "listProjectForTree.do",
            dataPlain: true,       //该属性用以启用当前 easyui-tree 控件对平滑数据格式的支持
            toggleOnClick: false,
            enableContextMenu: false,
            onClick: function(node){
            	var params = {};
            	windowparam = node.id;
				params['fid'] = node.id;
				grid.datagrid('reload',params); 
			}
    });
});  
	//新增项目
	function doAdd() {
		var url = '${request.contextPath}/xadmin/work/projectWindow.do?windowparam='+windowparam;
		var mwin = top.modalwindow(url, grid,{width:550, height:400,title:'新增项目信息',
		    buttons:[{
				text:'保存',
				iconCls:"icon-save",
				handler:function(){
					mwin.find('iframe')[0].contentWindow.saveProject($('#tree'));
				}
			}, top.btn_close]   
		});
	}
	//工具栏修改角色
	function doEdit() {
		var selected = grid.datagrid('getSelected');
		if(!selected){
			$.messager.alert('提示',"请选择相关数据进行操作！");
			return;
		}
		//
		var url = '${request.contextPath}/xadmin/work/projectWindow.do?projectid='+selected.projectid;
		var mwin =  window.top.modalwindow(url , grid,{ width:550, height:400,title:'修改项目信息',
		    buttons:[{
				text:'保存',
				iconCls:"icon-save",
				handler:function(){
					mwin.find('iframe')[0].contentWindow.saveProject($('#tree'));
				}
			}, top.btn_close]   
		});
	}
	//工具栏删除角色
	function doDel(){
		var selected = grid.datagrid('getSelected');
		if(!selected){
			$.messager.alert('提示',"请选择相关数据进行操作！");
			return;
		}
		$.messager.confirm('系统提示', '<br>&nbsp;&nbsp;&nbsp;&nbsp;你确定要删除该信息?', function(r) {
			if (r) {
				$.post("delProject.do", { "projectid": selected.projectid},
				   function(data){
				   	grid.datagrid('reload'); 
				   	top.messagershow(data);				   	
				});
			}
		});
	}
</script>
</head>
<body class="easyui-layout">
<div data-options="region:'west',iconCls:'icon-mini-add',title:'项目列表',split:true" style="width:180px;">
	<div class="easyui-panel" data-options='fit:true,border:false'> 
		<ul id="tree"></ul>
	</div>
</div>   
<div data-options="region:'center'">
<table id="projectgrid" data-options="fit:true,border:false"></table>
</div>  
</body>
</html>